﻿using SF.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SF.Ucenter.mycenterusers
{
    public partial class myusers : System.Web.UI.Page
    {
        public Model.sf_user_info userInfo;
        public string userMsg, userTitle, appWhere;
        BLL.sf_user_info userBll = new BLL.sf_user_info();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                /*验证用户是否登录*/
                if (Session[DTKeys.SESSION_ADMIN_INFO] == null)
                {
                    Response.Redirect("index.aspx");
                }
                userInfo = Session[DTKeys.SESSION_ADMIN_INFO] as Model.sf_user_info;
                appWhere = Utils.getWhereByInfo(userInfo.busnieseNum,userInfo.appNum,userInfo.templatesNum);
                int level = Request["level"] == null ? 0 : Convert.ToInt32(Request["level"]);
                BindData(level);
            }
        }
        //绑定用户数据
        public void BindData(int level)
        {
            userTitle = level == 1 ? "一级会员" : level == 2 ? "二级会员" : level == 3 ? "三级会员" : "朋友圈推广";
            DataTable dt = level == 1 || level == 4 ? userBll.GetList(" fatherKey='" + userInfo.inviteKey + "' and " + appWhere).Tables[0] : level == 2 ? userBll.getTwoUsers(userInfo.inviteKey, appWhere) : userBll.getThreeUsers(userInfo.inviteKey, appWhere);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                userMsg += "<div class='item'><div class='itemtitle fl'  style='width:35%;margin-left:14%;'><img src='" + dt.Rows[i]["photoUri"] + "' /></div><div class='salesnum fl'  style='width:40%;margin-left:6%;padding-top:8%;'>" + dt.Rows[i]["nickName"] + "</div><div class='clearfl'></div></div>";
            }
        }
    }
}